package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportFireComSenseDto;
import com.yqg.protection.entity.FireComSense;
import com.yqg.protection.mapper.FireComSenseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 9:49
 * description:
 */
@Component
public class FireComSenseListener extends AnalysisEventListener<ImportFireComSenseDto> {

    @Autowired
    private FireComSenseMapper fireComSenseMapper;

    @Override
    public void invoke(ImportFireComSenseDto importFireComSenseDto, AnalysisContext analysisContext) {
        FireComSense fireComSense = new FireComSense();
        BeanUtil.copyProperties(importFireComSenseDto, fireComSense, true);
        fireComSense.setIsDelete(0);
        fireComSenseMapper.insert(fireComSense);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
